#!/bin/sh

set -e
cur_path=$(pwd)

echo "start to prepare build env"
chmod +x /root/repo/ci-repos/.common_scripts/common.sh
source /root/repo/ci-repos/.common_scripts/common.sh
set_gitee_hosts
prepare_git $1 $2
prepare_conan2 $3 $4

sh install_local.sh
prepare_sdk

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DT_SCRIPT="${SCRIPT_DIR}/dt.py"
TEST_TYPE="it"
MANIFEST_PROFILE="~/manifest/build/profiles/profile.dt.ini"
TEST_PATH="tests/integrationtests/"


if [ ! -f "${DT_SCRIPT}" ]; then
    echo "Error: Missing ${DT_SCRIPT}"
    exit 1
fi

git config --global user.name test
git config --global user.email test

PY_ARGS="--test-type ${TEST_TYPE}"
PY_ARGS="${PY_ARGS} --test-path ${TEST_PATH}"
PY_ARGS="${PY_ARGS} --manifest-prof-path ${MANIFEST_PROFILE}"
if [ "${DRY_RUN:-false}" = "true" ]; then
    PY_ARGS="${PY_ARGS} --dry-run"
fi

#cd $cur_path
#python3 ${DT_SCRIPT} ${PY_ARGS} || {
#    echo "FATAL: UT failed with exit code $?"
#    exit 1
#}